package de.thm.exa.holders;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

public class Page
{
    // Private Fields
    private String www;
    private String hash;
    private ArrayList<Keyword> keywords;
    private double pageRank;
    
    // Constructors
    public Page(String www, String hash, double pageRank)
    {
        this.www = www;
        this.hash = hash;
        this.pageRank = pageRank;
        this.keywords = new ArrayList<>();
    }
    public Page(String www, String hash, double pageRank, ArrayList<Keyword> keywords)
    {
        this.www = www;
        this.hash = hash;
        this.pageRank = pageRank;
        this.keywords = keywords;
    }
    public Page(String www, String hash, double pageRank, Keyword... keywords)
    {
        this.www = www;
        this.hash = hash;
        this.pageRank = pageRank;
        this.keywords = new ArrayList<>();
        this.keywords.addAll( Arrays.asList(keywords) );
    }
    
    // Setter
    public void setWWW(String www) { this.www = www; }
    public void setHash(String hash) { this.hash = hash; }
    public void setPageRank(double pageRank) { this.pageRank = pageRank; }
    public void addKeyword(Keyword keyword) { keywords.add(keyword); }
    public void removeKeyword(int position) { this.keywords.remove(position); }
    public void removeKeyword(Keyword keyword) { this.keywords.remove(keyword); }
    public void removeKeywords(Map.Entry<String, String>... keywords) { this.keywords.removeAll( Arrays.asList(keywords) ); }
    public void clearKeywords() { this.keywords.clear(); }
    
    // Getter
    public String getWWW() { return www; }
    public String getHash() { return hash; }
    public ArrayList<Keyword> getKeywords() { return keywords; }
    public double getLinks() { return pageRank; }
    
    @Override
    public String toString() { return hash; }
}